<?php
//
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
if($_RQ['op']=='main'){
	$return=array();
	exi($return);
}
//获取门店
if($_RQ['op']=='getstores'){
	//获取第一个商品可选择门店
	//可选择门店
	$post=get_postdata();
	$id=intval($post['id']);
	$stores = array();
	if($id){
		$storeids = pdo_getcolumn('jy_weishop_goods',array('uniacid'=>$_SESSION['uniacid'],'id'=>$id),'storeids');
	}
	$storeids = $storeids?json_decode($storeids,true):array();
	if (empty($storeids)) {
		$stores = pdo_getall('jy_weishop_store',array('uniacid'=>$_SESSION['uniacid'],'status'=>1,'type'=>1));
	}else {
		foreach($storeids as $sv){
			$stores[]= pdo_get('jy_weishop_store',array('uniacid'=>$_SESSION['uniacid'],'status'=>1,'type'=>1,'id'=>$sv['id']));
		}
	}
	if($post['lat_lng']){
		foreach($stores as &$v){
			$v['lat_lng']=json_decode($v['lat_lng'],true);
			$v['pcd']= json_decode($v['pcd'],true);
			if($v['lat_lng']){				
				$v['distance']=cfc('tools')->getdistance($post['lat_lng']['lng'],$post['lat_lng']['lat'],$v['lat_lng']['lng'],$v['lat_lng']['lat']);
				$v['distance']=intval($v['distance']/1000);
			}
		}
		paixu($stores,'distance');
	}else{
		foreach($stores as $sv2){
			$sv2['pcd']= json_decode($sv2['pcd'],true);
		}
	}
	foreach($stores as $k=>$nv){
		if($nv['id']==$_SESSION['store_id']){
			$newstore=$nv;
			unset($stores[$k]);
		}
	}
	if($newstore){
		array_unshift($stores,$newstore);
	}
	$return['stores_count']=count($stores);
	$return['stores']=$stores;
	exi($return);
}
if($_RQ['op']=='getgoods'){
	$merchid =intval($_RQ['merchid']);
	if(!$merchid && $_RQ['frommerch']){
		$install = check_account_permission('jy_merch');
		if($install){	
			$merchid = pdo_getcolumn('jy_merch_user',array('mid'=>$_SESSION['uid']),'id');
		}
		$merchid=$merchid?:'-1';
	}
	$params=array('uniacid'=>$_SESSION['uniacid'],'status'=>1,'merchid'=>$merchid,'type <>'=>4);
	$params['onepluginname']='jy_textfee';
	if(!$merchid){
		$params['api_pluginname <>']='jy_merch';
	}
	if($_RQ['keyword']){		
			$params['title like']='%'.trim($_RQ['keyword']).'%';
			$return['params']['title']=$_RQ['keyword'];	
	}
	if($_RQ['cid']){
		$params['ccate']=intval($_RQ['cid']);
	}
	if($_RQ['order']=='isrecommand'){
		$params['saletype likes']=array('1');
	}
	if($_RQ['order']=='isnew'){
		$params['saletype likes']=array('2');
	}
	if($_RQ['order']=='ishot'){
		$params['saletype likes']=array('3');
	}
	if($_RQ['order']=='isdiscount'){
		$params['isdiscount']=intval($_RQ['isdiscount']);
	}
	if($_RQ['order']=='issendfree'){
		$params['issendfree']=intval($_RQ['issendfree']);
	}
	if($_RQ['order']=='istime'){
		$params['istime']=intval($_RQ['istime']);
	}
	if(!$merchid && $return['shopset']['no_showmerch']==1){
		$params['merchid']=0;
	}
	$params['onepluginname']='jy_textfee';
	//按点赞数排序作品
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$list=pdo_getslice('jy_weishop_goods',$params,array($pindex,$psize),$total,$fields,'','salenum desc, id desc');
	if(!$list){
		//exi('none');
	}
	if($list){
		$jy_commission=$this->plugin_exists('jy_commission');
		foreach($list as &$item){
			$item['createtime']=date('Y-m-d H:i:s',$item['createtime']);
			if($jy_commission){
				$item['groupaddfee']=model('jy_commission/model')->getgroupaddfee($item);
				$item['price'] +=$item['groupaddfee'];
			}
		}
	}
	
	exi($list);
}
if($_RQ['op']=='wxapp_tplids'){
	$names=$_RQ['name'];
	$pindex = max(1, intval($_RQ['page']));
	$psize = 3;
	$list=pdo_getall('core_account_tpl_template',array('uniacid'=>$_SESSION['uniacid'],'wxapp_id'=>$this->wxapp['id'],'name'=>$names),array($pindex,$psize),$total,'template_id');
	$return['list']=$list;
	exi($return);
}
if($_RQ['op']=='gettanmus'){
	$params=array('uniacid'=>$_SESSION['uniacid'],'deleted'=>0);
	$pindex = max(1, intval($_RQ['page']));
	$psize = 30;
	$total='';
	$fields=array('id','mid','status');
	$list=pdo_getslice('jy_weishop_order',$params,array($pindex,$psize),$total,$fields,'','createtime desc');
	foreach($list as &$item){
		$member=cfc('core')->member_show($item['mid']);
		$member['nickname']=mb_substr($member['nickname'],0,4,'utf-8').'***';
		$item['nickname']=$member['nickname'];
		$member['avatar']=$member['avatar']?:'../core/resource/images/nopic.jpg';
		$item['avatar']=tomedia($member['avatar']);
	}
	$return['list']=$list;
	exi($return);
}
if($_RQ['op']=='getgroup'){
	$return=array();
	$return['list']=pdo_getall('jy_weishop_goods_group',array('uniacid'=>$_SESSION['uniacid'],'mid'=>0,'isshow'=>1,'isrecommand'=>1));
	exi($return);
}
if($_RQ['op']=='getgoods'){
	$return=array();
	$return['goods']=pdo_get('jy_weishop_goods',array('uniacid'=>$_SESSION['uniacid'],'productsn'=>$_RQ['productsn']));
	exi($return);
}
if($_RQ['op']=='getrecommands'){
	$onepluginname=model('jy_weishop/goods')->is_onegoods($_SESSION['current_plugin'],$_RQ['pluginname']);
	if($onepluginname){//开启独立商品
			$groupspram['onepluginname']=$onepluginname;
			$return['params']['onepluginname']=$onepluginname;
	}else{
			$groupspram['onepluginname']='';
	}
	$parameter=array(
		'fields'=>array('id','title','subtitle','image','merchid','price','unit','marketprice','status','total','active_plugin','active_id','salenum','pluginname'),
		'limit'=>$_SESSION['os']=='windows'?10:6,
		'istomedia'=>true,
		'orderby'=>'paixu desc, salenum desc , id desc ',
	);
	$parameter['params']=array('saletype likes'=>array('1'),'uniacid'=>$_SESSION['uniacid'],'status'=>1,'type <>'=>4);
	$parameter['params']['onepluginname']='jy_textfee';
	if(!$merchid){
		$parameter['params']['api_pluginname <>']='jy_merch';
	}
	if($return['shopset']['no_showmerch']==1){
		$parameter['params']['merchid']=0;
	}
	if($_RQ['wxappjiaoyi']){
		$parameter['fields'][]='api_id';
		$parameter['params']['api_id >']=0;
		$parameter['params']['api_pluginname']='jy_wxappjiaoyib';
	}
	$list=model('jy_weishop/goods')->goods_list($parameter);
	if($list){
		$jy_commission=$this->plugin_exists('jy_commission');
		foreach($list as &$item){
			if($jy_commission){
				$item['groupaddfee']=model('jy_commission/model')->getgroupaddfee($item);
				$item['price'] +=$item['groupaddfee'];
			}
		}
	}
	if($_RQ['wxappjiaoyi']){
		foreach($list as &$v){
			$v['id']=$v['api_id'];
		}
	}
	$return['list']=$list;
	exi($return);
}
if($_RQ['op']=='getnewsgoods'){
	$parameter=array(
		'fields'=>array('id','title','subtitle','image','merchid','price','unit','marketprice','status','total','active_plugin','active_id','salenum','pluginname'),
		'limit'=>$_SESSION['os']=='windows'?10:6,
		'istomedia'=>true,
		'orderby'=>'paixu desc, salenum desc , id desc ',
	);
	//新品
	$parameter['params']=array('saletype likes'=>array('2'),'uniacid'=>$_SESSION['uniacid'],'status'=>1,'type <>'=>4);
	$parameter['params']['onepluginname']='jy_textfee';
	if($return['shopset']['no_showmerch']==1){
		$parameter['params']['merchid']=0;
	}
	if($_RQ['wxappjiaoyi']){
		$parameter['fields'][]='api_id';
		$parameter['params']['api_id >']=0;
		$parameter['params']['api_pluginname']='jy_wxappjiaoyib';
	}else{
		if(!$merchid){
			$parameter['params']['api_pluginname <>']='jy_merch';
		}
	}
	$new_list=model('jy_weishop/goods')->goods_list($parameter);
	if($new_list){
		$jy_commission=$this->plugin_exists('jy_commission');
		foreach($new_list as &$item){
			if($jy_commission){
				$item['groupaddfee']=model('jy_commission/model')->getgroupaddfee($item);
				$item['price'] +=$item['groupaddfee'];
			}
			$item['options']=pdo_get('jy_weishop_goods_option',array('goodsid'=>$item['id'],'uniacid'=>$_SESSION['uniacid']),array('id','stock','specs','price'));
			if($item['options']){
				$specids = explode("_", $item['options']['specs']);
				$selespename = array();
				if($specids){
					foreach($specids as $k=>$sp){
						$spec_item=pdo_get('jy_weishop_goods_spec_item',array('id'=>$sp,'uniacid'=>$_SESSION['uniacid']),array('id','title'));
						$selespename[]=$spec_item['title'];
					}
				}
				$item['optiontitle']= $selespename;
			}
		}
	}
	if($_RQ['wxappjiaoyi']){
		foreach($new_list as &$v){
			$v['id']=$v['api_id'];
		}
	}
	$return['list']=$new_list;
	exi($return);
}
if($_RQ['op']=='gethot_goods'){	
	$pindex = max(1, intval($_RQ['page']));
	$psize = 9;
	$total='';
	$parameter=array(
		'fields'=>array('id','title','subtitle','image','merchid','price','unit','marketprice','status','total','active_plugin','active_id','salenum','pluginname'),
		'limit'=>array($pindex,$psize),
		'istomedia'=>true,
		'orderby'=>'paixu desc, salenum desc , id desc ',
	);
	$parameter['params']=array('uniacid'=>$_SESSION['uniacid'],'status'=>1,'type <>'=>4);
	if($_RQ['order']=='star'){
		$parameter['orderby']='star desc ,salenum desc ,paixu desc, id desc ';
	}elseif($_RQ['order']=='salenum'){
		$parameter['orderby']='salenum desc ,paixu desc,  id desc ';
	}else{
		$parameter['params']['saletype likes']=array('3');
	}
	$parameter['params']['onepluginname']='jy_textfee';
	if($return['shopset']['no_showmerch']==1){
		$parameter['params']['merchid']=0;
	}
	if($_RQ['wxappjiaoyi']){
		$parameter['fields'][]='api_id';
		$parameter['params']['api_id >']=0;
		$parameter['params']['api_pluginname']='jy_wxappjiaoyib';
	}else{
		if(!$merchid){
			$parameter['params']['api_pluginname <>']='jy_merch';
		}
	}
	$list=model('jy_weishop/goods')->goods_list($parameter);
	$jy_commission=$this->plugin_exists('jy_commission');
	foreach($list as &$itemv){
			$itemv['likes']=pdo_count('jy_weishop_member_history',array('uniacid'=>$_SESSION['uniacid'],'goodsid'=>$itemv['id'],),'id');
			$cartinfo=pdo_get('jy_weishop_member_cart',array('selected'=>1,'goodsid'=>$itemv['id'],'mid'=> $_SESSION['uid'], 'uniacid' => $_SESSION['uniacid']));
			$cartinfo['total']=pdo_getsum('jy_weishop_member_cart',array('selected'=>1,'goodsid'=>$itemv['id'],'mid'=> $_SESSION['uid'], 'uniacid' => $_SESSION['uniacid']),'total');
			$itemv['cartid']=$cartinfo['id']?:0;
			$itemv['carttotal']=$cartinfo['total']?:0;
			$itemv['cartprice']=$cartinfo['price']?:0;
			$itemv['cartoptionid']=$cartinfo['optionid']?:0;
			$itemv['cartid']=$itemv['cartid']?:0;
			$itemv['carttotal']=$itemv['carttotal']?:0;
			$itemv['specs_list']=array();
			$itemv['options']=pdo_get('jy_weishop_goods_option',array('goodsid'=>$itemv['id'],'uniacid'=>$_SESSION['uniacid']),array('id','stock','specs','price'));
			if($itemv['options']){
				$specids = explode("_", $itemv['options']['specs']);
				$selespename = array();
				if($specids){
					foreach($specids as $k=>$sp){
						$spec_item=pdo_get('jy_weishop_goods_spec_item',array('id'=>$sp,'uniacid'=>$_SESSION['uniacid']),array('id','title'));
						$selespename[]=$spec_item['title'];
					}
				}
				$itemv['optiontitle']= $selespename;
			}
			if($_SESSION['is_tomedia']){
				$itemv['image']=$itemv['image']?tomedia($itemv['image']):'';
				$itemv['video']=$itemv['video']?tomedia($itemv['video']):'';
			}
			if($this->plugin_exists('jy_merch')){
				$itemv['merchname']=pdo_getcolumn('jy_merch_user',array('id'=>$itemv['merchid']),'merchname');
			}
			if($_RQ['wxappjiaoyi']){
				$itemv['id']=$itemv['api_id'];
			}
			if($jy_commission){
				$itemv['groupaddfee']=model('jy_commission/model')->getgroupaddfee($itemv);
				$itemv['price'] +=$itemv['groupaddfee'];
			}
	}
	$return['list']=$list;
	exi($return);
}
if($_RQ['op']=='gethistorygoods'){
	//看了又看（按时间）
	$parameter=array(
				'params'=>array('uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid']),
				'orderby'=>'createtime desc',
				'limit'=>'6',
	);
	$history=pdo_getlist('jy_weishop_member_history',$parameter);
	foreach($history as $ke=>&$hiv){
			$hiv['goodsinfo']=pdo_get('jy_weishop_goods',array('uniacid'=>$_SESSION['uniacid'],'status'=>'1','id'=>$hiv['goodsid']),array('id','title','image','price','total','salerealnum','salenum'));
			if(!$hiv['goodsinfo']){
				unset($history[$ke]);
			}
	}
	$return['list']=$history;
	exi($return);
}
if($_RQ['op']=='specs_list'){
		$goodsid=intval($_RQ['goodsid']);
		$spsids=$_RQ['specs'];
		//规格
		$specs_list=pdo_getall('jy_weishop_goods_spec',array('goodsid'=>$goodsid,'uniacid'=>$_SESSION['uniacid']),array('id','title'),'','paixu asc');
		//已选规格
		$selectspecs = explode('_',$spsids);
		$selespename = '';
		if($specs_list){
				foreach($selectspecs as $spv){
					$spsitem=pdo_get('jy_weishop_goods_spec_item',array('id'=>$spv,'uniacid'=>$_SESSION['uniacid']),array('id','title'),'','paixu asc');
					if($spsitem['title']){
						$selespename .=$spsitem['title'].'，';
					}
				}
				foreach($specs_list as $k=>&$sp){
					$sp['items']=pdo_getall('jy_weishop_goods_spec_item',array('specid'=>$sp['id'],'uniacid'=>$_SESSION['uniacid']),array('id','title'),'','paixu asc');
				}
				if(count($specs_list)>0){
					$goods['optiontotal']=pdo_getsum('jy_weishop_goods_option',array('uniacid'=>$_SESSION['uniacid'],'goodsid'=>$goodsid),'stock');
					if($goods['optiontotal']<0){
						$goods['canbuy']==false;
					}else{
						$goods['canbuy']==true;
					}
				}
		}
		$return['specid']=$selectspecs;
		$return['list']=$specs_list;
		exi($return);
}
if($_RQ['op']=='get_optionsid'){
	$post=get_postdata();
	$id=$post['goodsid']?:$_SESSION['goodsid'];
	$store_id=$this->session('store_id');
	if(!$id){
		exi('请先选择商品！','error');
	}
	if($post['storeid']){
		
	}
	//规格
	$specids=explode('_',$post['specid']);
	
	//已选规格
	$selespename = '';
	if($specids){
			foreach($specids as $k=>$sp){
				$spec_item=pdo_get('jy_weishop_goods_spec_item',array('id'=>$sp,'uniacid'=>$_SESSION['uniacid']),array('id','title'));
				$selespename .=$spec_item['title'].'，';
			}
	}
	$optionsid=pdo_getcolumn('jy_weishop_goods_option',array('goodsid'=>$id,'specs'=>$post['specid']),'id');
	//默认商品规格价格：
	$goods=pdo_get('jy_weishop_goods',array('uniacid'=>$_SESSION['uniacid'],'id'=>$id));
	$goods['optionid']=$optionsid;
	$goods['storeid']=$store_id;
	$goods=model('jy_weishop/activity')->get_upgoods($goods);
	$return['options']=$goods['options'];
	$return['options']['thumb']=$return['options']['thumb']?tomedia($return['options']['thumb']):tomedia($goods['image']);
	if($post['isdish']){
		$return['carttotal']=pdo_getcolumn('jy_weishop_member_cart',array('selected'=>1,'optionid'=>$return['options']['id'],'goodsid'=>$id,'mid'=> $_SESSION['uid'], 'uniacid' => $_SESSION['uniacid']),'total');
	}else{
		$return['carttotal']=pdo_getcolumn('jy_weishop_member_cart',array('optionid'=>$return['options']['id'],'goodsid'=>$id,'mid'=> $_SESSION['uid'], 'uniacid' => $_SESSION['uniacid']),'total');
	}
	$return['carttotal']=$return['carttotal']?:0;
	$return['selespename'] = $selespename;
	exi($return);
}
if($_RQ['op']=='getmerchs'){
	$jy_merch = $this->plugin_exists('jy_merch');
	if(!$jy_merch){
		exi(array('list'=>array()));
	}
	//获取最近50家店
	if($_RQ['lat'] || $_RQ['lng']){
		$lat_lng=array('lat'=>$_RQ['lat'],'lng'=>$_RQ['lng']);
		$this->session('lat_lng',$lat_lng);
	}
	$lat_lng=$this->session('lat_lng');
	$params=array(
		'uniacid'=>$_SESSION['uniacid'],
		'status'=>1,
		'merchname <>'=>'',
		'lat_lng <>'=>'',
	);
	if($_RQ['cid']){
		$params['cateid']=intval($_RQ['cid']);
		$return['params']['cid']=intval($_RQ['cid']);
	}
	$orderby='isrecommand desc, salenum desc, id desc';
	if(trim($_RQ['order']) && trim($_RQ['order'])!='all'){
		$order=trim($_RQ['order']);
		if($order=='salenum'){
			$orderby='salenum desc, isrecommand desc, id desc';
			$orderbykey='salenum';
		}
		if($order=='sudu'){
			$orderby='sudu desc, isrecommand desc, salenum desc, id desc';
			$orderbykey='sudu';
		}
		if($order=='star'){
			$orderby='star desc, isrecommand desc, salenum desc, id desc';
			$orderbykey='star';
		}
		if($order=='brand'){
			$params['isbrand']=1;
		}
		if($order=='you'){
			$orderby='isrecommand desc, salenum desc, id desc';
			$orderbykey='isrecommand';
		}
		if($order=='out_pay'){
			$orderby='out_pay desc, isrecommand desc, salenum desc, id desc';
			$orderbykey='out_pay';
		}
		if($order=='out_price'){
			$orderby='out_price desc, isrecommand desc, salenum desc, id desc';
			$orderbykey='out_price';
		}
		$return['params']['order']=trim($_RQ['order']);
	}
	if(intval($_RQ['star'])){
		$params['star >']=intval($_RQ['star'])-0.2;
		$return['params']['star']=intval($_RQ['star']);
	}
	if(trim($_RQ['keyword'])){
		$params['merchname like']='%'.trim($_RQ['keyword']).'%';
		$return['params']['keyword']=trim($_RQ['keyword']);
	}
	$pindex = max(1, 1);
	$parameter=array(
		'params'=>$params,
		'limit'=>array($pindex,10000),//获取所有
		'fields'=>array('id','merchname','out_price','lat_lng','logo','topimg','cateid','onlinetime'),
		'key'=>'id',
		'orderby'=>$orderby,
		'orderbykey'=>$orderbykey,
	);
	$merchs=model('jy_merch/model')->getmerch($parameter,$_RQ['limit'],$lat_lng,intval($_RQ['page']),intval($_RQ['juli']));
	$citypeisong=plugin('jy_weishop')->plugin_setting('citypeisong');
	foreach($merchs as $k=>&$v){
			$v['goodsnum']=pdo_count('jy_weishop_goods',array('merchid'=>$v['id']),'id');
			$v['logo']=$v['logo']?tomedia($v['logo']):'';
			$v['topimg']=$v['topimg']?tomedia($v['topimg']):'';
			$v['onlinetime']=json_decode($v['onlinetime'],true);
			$v['onlinetime']['start']=$v['onlinetime']['start']?:'7:00';
			$v['onlinetime']['end']=$v['onlinetime']['end']?:'22:00';	
			$days=date('Y-m-d',TIMESTAMP);
			$star=strtotime($days.' '.$v['onlinetime']['start']);
			$end=strtotime($days.' '.$v['onlinetime']['end']);
			if($star>TIMESTAMP || TIMESTAMP>$end){
				$v['offline']=1;
			}
			if($v['juli']<10){
				$v['peisongtime']=$v['juli']*5+28;
			}else if($v['juli']<30){
				$v['peisongtime']=$v['juli']*3+28;
			}else{
				$v['peisongtime']=$v['juli']*1+28;
			}
			$v['out_juli']=$v['out_juli']>0?$v['out_juli']:8;
			$v['out_price']=$v['out_price']>0?$v['out_price']:$citypeisong['out_price'];
			$pindex = max(1, 1);
			$psize = 6;
			$params=array('uniacid'=>$_SESSION['uniacid'],'status'=>1,'nochecked'=>0,'no_showsys'=>0,'merchid'=>$v['id'],'type <>'=>4);
			$fields=array('id','title','price','image','unit','originalprice','nochecked');
			$goods=pdo_getslice('jy_weishop_goods',$params,array($pindex,$psize),$total,$fields,'','salenum desc, id desc');
			foreach($goods as &$gv){
					$gv['image']=tomedia($gv['image']);
					$gv['originalprice']=$gv['originalprice']?:$gv['price']*1.2;
					$gv['originalprice']=price($gv['originalprice']);
					$v['tags']=pdo_getcolumn('jy_weishop_goods_comments',array('uniacid'=>$_SESSION['uniacid'],'goodsid'=>$gv['id']),'tags');
			}
			$v['goods']=$goods;
			$v['coupons']=model('jy_weishop/coupon')->getmerchcoupon($v['id'],1);
			$v['salenum']=pdo_getsum('jy_weishop_order_goods',array('uniacid'=>$_SESSION['uniacid'],'merchid'=>$v['id']),'total');
			
	}
	$return['list']=array_values($merchs);
	exi($return);
}
if($_RQ['op']=='getprovince'){
	$res=array('province'=>cfc('tools')->pcd());
	exi($res);
}
if($_RQ['op']=='getgoodsdetail'){
	$return=model('jy_weishop/goods_item')->get_goodsitem($return);
	exi($return);
}
if($_RQ['op']=='upstoreid'){
	$_SESSION['store_id']=$_RQ['store_id'];
	exi('success');
}
if($_RQ['op']=='get_upgoods'){
	$id=$_RQ['id'];
	$storeid=$_RQ['storeid'];
	if($storeid){
		$_SESSION['store_id']=$storeid;
	}
	$goods=pdo_get('jy_weishop_goods',array('id'=>$id,'uniacid'=>$_SESSION['uniacid']));
	$goods=model('jy_weishop/activity')->get_upgoods($goods);
	$return=array(
		'options'=>$goods['options'],
		'price'=>$goods['price'],
		'store_isopen'=>$goods['store_isopen'],
		'storeid'=>$goods['storeid'],
		'active_plugin'=>$goods['active_plugin'],
		'pluginname'=>$goods['pluginname'],
		'active'=>$goods['active'],
		'storeid'=>$goods['storeid'],
		'canbuy'=>$goods['total']>0?:false,
	);
	exi($return);
}
//获取地址
if($_RQ['op']=='get_addresslist'){
	if($return['shopset']['addressdiyform']){
		$addressdiyform=pdo_getcolumn('jy_weishop_diyform_temp',array('id'=>$return['shopset']['addressdiyform'],'uniacid'=>$_SESSION['uniacid']),'diyformfields');
		$addressdiyform=$addressdiyform?json_decode($addressdiyform,true):array();
	}
	$return['list']=pdo_getall('core_address',array('uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid']));
	foreach($return['list'] as &$av){
		$av['pcd']=json_decode($av['pcd'],true);
		$av['diyfields']=$av['diyfields']?json_decode($av['diyfields'],true):$addressdiyform;
	}
	exi($return);
}
?>